home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / examples / hostlookup.lsp < prev    next >
Encoding:
Lisp/Scheme  |  1991-11-28  |  2.8 KB  |  81 lines

  1. ; -*-Lisp-*-
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; File:         hostlookup.lsp
  5. ; RCS:          $Header: hostlookup.lsp,v 1.2 91/10/05 17:34:57 mayer Exp $
  6. ; Description:  A lamo application that uses X_REFRESH_DISPLAY to 
  7. ;        popup and display contents of a "working dialog"
  8. ;        before a time-consuming subprocess begins to execute.
  9. ;        
  10. ;        Note that X_REFRESH_DISPLAY is only defined on HPUX WINTERPs.
  11. ;        You may be able to get this working for your machine as well...
  12. ;        see src-server/w_utils.c:Wut_Prim_X_REFRESH_DISPLAY() and
  13. ;        src-server/utils.c for details....
  14. ; Author:       Niels Mayer, HPLabs
  15. ; Created:      Fri Feb  8 19:59:47 1991
  16. ; Modified:     Thu Nov 21 20:57:15 1991
  17. ; Language:     Lisp
  18. ; Package:      N/A
  19. ; Status:       X11r5 contrib tape release
  20. ;
  21. ; WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  22. ; XLISP version 2.1, Copyright (c) 1989, by David Betz.
  23. ;
  24. ; Permission to use, copy, modify, distribute, and sell this software and its
  25. ; documentation for any purpose is hereby granted without fee, provided that
  26. ; the above copyright notice appear in all copies and that both that
  27. ; copyright notice and this permission notice appear in supporting
  28. ; documentation, and that the name of Hewlett-Packard and Niels Mayer not be
  29. ; used in advertising or publicity pertaining to distribution of the software
  30. ; without specific, written prior permission.  Hewlett-Packard and Niels Mayer
  31. ; makes no representations about the suitability of this software for any
  32. ; purpose.  It is provided "as is" without express or implied warranty.
  33. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  34.  
  35.  
  36. (let (top-w edit-w dialog-w)
  37.  
  38.   (setq top-w
  39.     (send TOP_LEVEL_SHELL_WIDGET_CLASS :new "top-w"
  40.           :XMN_TITLE "Hostname lookup"
  41.           :XMN_ICON_NAME "Hostname lookup"
  42.           ))
  43.   (setq edit-w
  44.     (send XM_TEXT_WIDGET_CLASS :new :managed
  45.           "edit-w" top-w
  46.           :XMN_EDIT_MODE       :SINGLE_LINE_EDIT
  47.           :XMN_COLUMNS         80
  48.           ))
  49.  
  50.   (send edit-w :set_callback :XMN_ACTIVATE_CALLBACK '()
  51.     '(
  52.       (let ((hostname (send edit-w :get_string)))
  53.         (send dialog-w :set_values 
  54.           :XMN_MESSAGE_STRING (strcat "Looking up hostname " hostname)
  55.           )
  56.         (send dialog-w :manage)
  57.  
  58. ;;        (x_refresh_display 300)
  59.  
  60.         ;; If x_refresh_display isn't defined, you can substite the following ultra-kludge
  61.         (send dialog-w :update_display)
  62.         (system "sleep 0")
  63.         (send dialog-w :update_display)
  64.  
  65.         (let ((pipe (popen (strcat "grep -i '" hostname "' /etc/hosts") "r")))
  66.           (send edit-w :set_string (read-line pipe))
  67.           (pclose pipe)
  68.           )
  69.         )
  70.       (send dialog-w :unmanage)
  71.       ))
  72.    
  73.   (send top-w :realize)
  74.  
  75.   (setq dialog-w
  76.     (send XM_MESSAGE_BOX_WIDGET_CLASS :new :unmanaged :working_dialog
  77.           "working_dialog" top-w
  78.           ))
  79.  
  80.   )
  81.